package com.siebre.picclife.asynctask.service.support;

import java.util.List;

import org.springframework.jdbc.core.JdbcOperations;

import com.siebre.picclife.asynctask.model.Task;
import com.siebre.picclife.asynctask.service.TaskService;

/**
 * 
 * @author ZhangChi
 * @since 2015年4月3日
 */
public abstract class JdbcTaskService implements TaskService {
	
//	private JdbcQueue<Long> newTaskQueue;
//	private JdbcQueue<Long> failedTaskQueue;

	public JdbcTaskService(JdbcOperations jdbcOperations) {
//		newTaskQueue = new JdbcQueueBuilderFactory(jdbcOperations).backedBySql(
//				"select oid from Task where status=0 order by oid", new SingleColumnRowMapper<Long>(Long.class))
//				.fetchBy("update Task set status=1 where oid=? and status=0").build();
//		newTaskQueue = new JdbcQueueBuilderFactory(jdbcOperations).backedBySql(
//				"select oid from Task where status=3 order by oid", new SingleColumnRowMapper<Long>(Long.class))
//				.fetchBy("update Task set status=1, processor=:processor, startTime=:startTime where oid=:oid and status=3").build();
	}

	public List<Task> start(int maxCount) {
		return null;
	}

	public Task startById(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	public void completeTask(long id) {
		// TODO Auto-generated method stub
		
	}

	public void completeTaskWithFailure(long id, Throwable cause) {
		// TODO Auto-generated method stub
		
	}

	public int recover() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void completeTask(Task task) {
		task.complete();
	}

	public void completeTaskWithFailure(Task task, Throwable cause) {
		task.complete(cause);
	}

	public List<Task> restart(int maxCount) {
		return null;
	}

}
